package com.Txunda.fxw.ui.toolkit.text;

import android.annotation.SuppressLint;
import android.os.CountDownTimer;
import android.support.v4.content.ContextCompat;
import android.widget.TextView;

import com.Txunda.fxw.R;

/**
 * =======================================
 * 作   者：Hwangzj
 * 创建时间：2018/11/15 20:33
 * 代码描述：
 * 修改历史：
 * 说   明：
 * =======================================
 */
public class CodeCountDown extends CountDownTimer {
    private TextView textView;

    public CodeCountDown(long millisInFuture, long countDownInterval, TextView textView) {
        super(millisInFuture, countDownInterval);
        this.textView = textView;
    }

    @Override
    public void onFinish() {
        textView.setText("获取验证码");
        textView.setTextColor(ContextCompat.getColor(textView.getContext(), R.color.colorAccent));
        textView.setEnabled(true);

    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onTick(long l) {
        long residue = l / 1000;// 剩余时间
        textView.setText("重新获取" + "(" + residue + ")");
        textView.setTextColor(ContextCompat.getColor(textView.getContext(), R.color.bg_color));
        textView.setEnabled(false);

    }
}
